<?php


namespace App\Models\Traits;


trait Btn
{
    /**
     * 删除按钮控制
     */
    public function delBtn($currentRoutename)
    {
        $auths=session('admin_auths');

        if($auths === true){
            return '<a class="btn btn-danger del" href="'. route($currentRoutename,['id'=>$this]).' ">删除</a>';
        }

        $RouteName = array_filter(array_merge($auths,config('rbac.allow_route')));
        $bool = in_array($currentRoutename,$RouteName);
        if($bool){
            return  '<a class="btn btn-danger del" href="'. route($currentRoutename,['id'=>$this]).'">删除</a>';
        }else{
            return '';
        }

    }

    /**
     * 恢复按钮控制
     * @return string
     */
    public function restory($currentRoutename)
    {
        $auths=session('admin_auths');

        if($auths === true){
            return '<a class="btn btn-warning restorydel" href="'. route($currentRoutename,['id'=>$this]).' ">恢复</a>';
        }

        $RouteName = array_filter(array_merge($auths,config('rbac.allow_route')));
        $bool = in_array($currentRoutename,$RouteName);
        if($bool){
            return  '<a class="btn btn-warning restorydel" href="'. route($currentRoutename,['id'=>$this]).'">恢复</a>';
        }else{
            return '';
        }
    }
}
